package com.barunsw.bwf.neoarena_erp.firstaction_release_card;

import java.util.List;
import java.util.Locale;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.ResponseBody;

import com.barunsw.bwf.neoarena_erp.vo.FirstActionReleseCardVo;

@Controller
@RequestMapping("/firstaction_release_card")
public class FirstActionReleseCardController {
	private static final Logger logger = LoggerFactory.getLogger(FirstActionReleseCardController.class);
	
	@Autowired
	private FirstActionReleseCardService firstActionReleseCardService;
	
	@RequestMapping(value = "", method = RequestMethod.GET)
	public String home(Locale locale, Model model) {
		return "firstaction_release_card/firstaction_release_card";
	}

	@RequestMapping(value = "/list", method = RequestMethod.GET)
	public @ResponseBody List<FirstActionReleseCardVo> list(
			@RequestBody @RequestParam(value="deptCode", required=false) String deptCode,
			@RequestBody @RequestParam(value="startDate", required=false) String startDate,
			@RequestBody @RequestParam(value="endDate", required=false) String endDate,
			@RequestBody @RequestParam(value="customerCode", required=false) String customerCode,
			@RequestBody @RequestParam(value="returnType", required=false) String returnType
		
		) throws Exception {
		
		FirstActionReleseCardVo firstActionReleseCardVo = new FirstActionReleseCardVo();
		firstActionReleseCardVo.setDeptCode(deptCode);
		firstActionReleseCardVo.setStartDate(startDate);
		firstActionReleseCardVo.setEndDate(endDate);
		firstActionReleseCardVo.setCustomerCode(customerCode);
		firstActionReleseCardVo.setReturnType(returnType);
		
		List<FirstActionReleseCardVo> firstActionReleseCardList = firstActionReleseCardService.selectList(firstActionReleseCardVo);
		
		return firstActionReleseCardList;
	}
	
	@RequestMapping(value = "/detailList", method = RequestMethod.GET)
	public @ResponseBody List<FirstActionReleseCardVo> detailList(
			@RequestBody @RequestParam(value="firstactionCode", required=false) String firstactionCode,
			@RequestBody @RequestParam(value="returnType", required=false) String returnType
		
		) throws Exception {
		
		FirstActionReleseCardVo firstActionReleseCardVo = new FirstActionReleseCardVo();
		firstActionReleseCardVo.setFirstactionCode(firstactionCode);
		firstActionReleseCardVo.setReturnType(returnType);
		
		List<FirstActionReleseCardVo> firstActionReleseCardDetailList = firstActionReleseCardService.selectDetailList(firstActionReleseCardVo);
		
		return firstActionReleseCardDetailList;
	}
}
